// Package blacklist 模型
package blacklist

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

const (
	_ = iota
	PASSENGER
	DRIVER
)

type Blacklist struct {
	models.BaseModel
	UserId  uint64 `gorm:"column:user_id" db:"user_id" json:"user_id" form:"user_id"`     //用户ID
	BlackId uint64 `gorm:"column:black_id" db:"black_id" json:"black_id" form:"black_id"` //拉黑人ID
	Type    uint8  `gorm:"column:type" db:"type" json:"type" form:"type"`                 //黑名单类型：1乘客拉黑司机，2：司机拉黑乘客
	Reason  string `gorm:"type:varchar(255)" db:"reason" json:"reason" form:"reason"`     //拉黑原因
	models.CommonTimestampsField
}

func (blacklist *Blacklist) Create() {
	database.DB.Create(&blacklist)
}

func (blacklist *Blacklist) Save() (rowsAffected int64) {
	result := database.DB.Save(&blacklist)
	return result.RowsAffected
}

func (blacklist *Blacklist) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&blacklist)
	return result.RowsAffected
}
